<template>
    
  <div>
        
    <div class="logo">
            <span>青梧商城</span>       <el-button
        type="info"
        style="float: right;  margin-right: 30px"
        @click="outLogin"
        >退出</el-button
      >
          
    </div>
        <el-container>
            <el-menu
        default-active="2"
        class="el-menu-vertical-demo"
        background-color="#000"
        text-color="#fff"
        active-text-color="#ffd04b"
        style="width: 200px;  height: 800px"
        router
      >
                <el-submenu>
                    <template slot="title">
                        <i class="el-icon-user"></i>             <span>{{
              menus[0].name
            }}</span>
                      </template
          >
                    <el-menu-item-group>
                        <el-menu-item :index="users[0].link">{{
              users[0].name
            }}</el-menu-item>
                      </el-menu-item-group
          >
                    <el-submenu
            :index="index1.toString()"
            v-for="(item1, index1) in usersList"
            :key="index1"
          >
                        <template slot="title">{{ item1.name }}</template>
                        <el-menu-item
              :index="item2.link"
              v-for="(item2, index2) in item1.children"
              :key="index2"
              >{{ item2.name }}</el-menu-item
            >
                      </el-submenu
          >
                  </el-submenu
        >

                <el-submenu
          :index="index.toString()"
          v-for="(item, index) in bottomList"
          :key="index"
        >
                    <template slot="title">
                        <i class="el-icon-location"></i>             <span>{{
              item.name
            }}</span>
                      </template
          >
                    <el-menu-item-group
            v-for="(item1, index1) in item.children"
            :key="index1"
          >
                        <el-menu-item :index="item1.link">{{
              item1.name
            }}</el-menu-item>
                      </el-menu-item-group
          >
                  </el-submenu
        >
              </el-menu
      >
            <el-main>
                <router-view style="margin: 10px 10px"></router-view>
              </el-main
      >
          </el-container
    >
      
  </div>
</template>

<script>
export default {
  data() {
    return {
      menus: [],
      users: {},
      usersList: [],
      bottomList: [],
    };
  },
  created() {
    this.$axios.get("http://pc.qingwuit.com/api/Admin/menus").then((res) => {
      console.log(res.data);
      this.menus = res.data;
      this.users = res.data[0].children.slice(0, 1);
      this.usersList = res.data[0].children.slice(1, 5);
      this.bottomList = res.data.slice(1, 11);
      console.log(this.bottomList);
    });
  },
  methods: {
    outLogin() {
      this.$store.commit("outLogin");
      this.$router.push("/admin/login");
      this.$message.success("退出登录成功");
    },
  },
};
</script>
<style scoped>
.logo {
  width: 100%;
  height: 50px;
  background: #000;
  font-size: 30px;
  color: #ffffff;
}
.top {
  width: 88%;
  height: 40px;
  background: #ffffff;
}
</style>
* {
  margin: 0;
  padding: 0;
}
.tou {
  width: 199px;
  height: 100%;
  background-color: #545c64;
}
.tou1 {
  text-align: center;
  width: 108px;
  height: 100%;
  background-color: #e9eef3;
}
.el-header {
  display: flex;
  justify-content: space-between;
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #000;
  color: #fff;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  line-height: 160px;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>